/**
 * 
 */
package teamproject.graphEditor;

import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.awt.event.MouseWheelListener;

import edu.uci.ics.jung.algorithms.layout.Layout;
import edu.uci.ics.jung.visualization.VisualizationViewer;

/**
 * @author Christina
 * 
 */
@SuppressWarnings("serial")
public class CustomVisualizationViewer<V, E> extends VisualizationViewer<V, E> {

	/**
	 * @param layout
	 */
	public CustomVisualizationViewer(Layout<V, E> layout) {
		super(layout);

	}

	@Override
	public void setGraphMouse(GraphMouse graphMouse) {
		this.graphMouse = graphMouse;
		MouseListener[] ml = getMouseListeners();
		for (int i = 0; i < ml.length; i++) {
			if (ml[i] instanceof GraphMouse) {
				removeMouseListener(ml[i]);
			}
		}
		MouseMotionListener[] mml = getMouseMotionListeners();
		for (int i = 0; i < mml.length; i++) {
			if (mml[i] instanceof GraphMouse) {
				removeMouseMotionListener(mml[i]);
			}
		}
		MouseWheelListener[] mwl = getMouseWheelListeners();
		for (int i = 0; i < mwl.length; i++) {
			if (mwl[i] instanceof GraphMouse) {
				removeMouseWheelListener(mwl[i]);
			}
		}
		addMouseListener(graphMouse);
		addMouseMotionListener(graphMouse);
	}

}
